package team.first.movieapiv1pro.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @Author: HAPPY
 * @Project_name: project
 * @Package_name: team.first.movieapiv1pro.config
 * @Date: 2021/11/25 20:13
 * @Description:
 */
@EnableSwagger2
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .select()// 通过.select()方法，去配置扫描接口,RequestHandlerSelectors配置如何扫描接口
                .apis(RequestHandlerSelectors.basePackage("team.first.movieapiv1pro"))
                .build();
    }

    //配置文档信息
    private ApiInfo apiInfo() {
        Contact contact = new Contact("杨欢乐、贾倩倩、迪丽达娜、杨依衡、张仕杰、高佳乐", "https://blog.csdn.net/happy488127311?spm=1000.2115.3001.5343", "488127311@qq.com");
        return new ApiInfo(
                "moive-api-v1 接口说明文档", // 标题
                "实验2的影评系统第二版的接口说明文档", // 描述
                "v1.0", // 版本
                "https://gitee.com/database-study/movie", // 组织链接
                contact, // 联系人信息
                "无", // 许可
                "无", // 许可连接
                new ArrayList<>()// 扩展
        );
    }
}
